/*
 * @(#)Authorization.java 2009-3-17
 * Copyright (c) 2008-2015 by CJK
 * All rights reserved.
 */
package net.beyond.common.auth;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;

/**
 * 
 * @author Shmiluyu
 * @version 1.000 2009-3-17
 */
@Service("util.authorization")
public class Authorization {
	@Resource(name = "util.authContextProvider")
	private AuthContextProvider authContextProvider;
	@Resource(name = "util.authRepProvider")
	private AuthRepositoryProvider authRepProvider;

	public boolean accept(HttpServletRequest request) {
		if (authContextProvider == null || authRepProvider == null) {
			throw new RuntimeException("初始化不完整..");
		}
		return authRepProvider.checkHasThisPriv(authContextProvider
				.getAuthContext(request));
	}

	public AuthContextProvider getAuthContextProvider() {
		return authContextProvider;
	}

	public void setAuthContextProvider(AuthContextProvider authContextProvider) {
		this.authContextProvider = authContextProvider;
	}

	public AuthRepositoryProvider getAuthRepProvider() {
		return authRepProvider;
	}

	public void setAuthRepProvider(AuthRepositoryProvider authRepProvider) {
		this.authRepProvider = authRepProvider;
	}
}
